using System.ComponentModel.DataAnnotations;
using SqlSugar;
using RuoVea.ExSugar.Entity;

namespace Gantt.Server.Models;

/// <summary>
/// 定义甘特图中的任务模型
/// </summary>
[SugarTable(nameof(GanttTasks), "甘特图任务")]
public class GanttTasks : EntityBase
{
    [SugarColumn(ColumnDescription = "所属项目", IsNullable = false)]
    public long ProjectId { get; set; }
    /// <summary>
    /// 任务的标签或名称
    /// </summary>
    [Required]
    [StringLength(255)]
    [SugarColumn(ColumnDescription = "任务名称", IsNullable = false)]
    public string? Label { get; set; }

    /// <summary>
    /// 分配给任务的用户或负责人信息
    /// </summary>
    [SugarColumn(ColumnDescription = "用户", IsNullable = true)]
    public string? User { get; set; }

    /// <summary>
    /// 父级任务的ID，如果是子任务的话
    /// </summary>
    [SugarColumn(ColumnDescription = "父任务ID", IsNullable = true)]
    public long? ParentId { get; set; }

    /// <summary>
    /// 任务开始的时间
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "开始日期", IsNullable = false)]
    public DateTime Start { get; set; }

    /// <summary>
    /// 任务结束的时间
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "结束日期", IsNullable = false)]
    public DateTime End { get; set; }

    /// <summary>
    /// 实际开始日期
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "实际开始日期", IsNullable = true)]
    public DateTime? RealStart { get; set; }

    /// <summary>
    /// 实际结束日期
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "实际结束日期", IsNullable = true)]
    public DateTime? RealEnd { get; set; }

    /// <summary>
    /// 任务持续的时间（例如天数）
    /// </summary>
    [SugarColumn(ColumnDescription = "持续时间", IsNullable = true)]
    public long? Duration { get; set; }

    /// <summary>
    /// 任务完成的百分比
    /// </summary>
    [SugarColumn(ColumnDescription = "完成百分比", IsNullable = true)]
    public int? Percent { get; set; } = 0;

    /// <summary>
    /// 与任务相关的项目ID
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "项目ID", IsNullable = false)]
    public long? TypeId { get; set; }

    /// <summary>
    /// 任务开始的标识符，可能用于与其他实体的关系
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "开始标识符", IsNullable = false)]
    public long? StatusId { get; set; }

    /// <summary>
    /// 任务的优先级标识符
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "优先级ID", IsNullable = false)]
    public long? LevelId { get; set; }

    /// <summary>
    /// 任务进度（与Percent可能类似，但用途略有不同）
    /// </summary>
    [SugarColumn(ColumnDescription = "进度", IsNullable = true)]
    public int? Progress { get; set; } = 0;

    /// <summary>
    /// 在视图中的展开状态，如是否折叠子任务
    /// </summary>
    [SugarColumn(ColumnDescription = "展开/折叠状态", IsNullable = true)]
    public int? Collapsed { get; set; }

    /// <summary>
    /// 该任务依赖于其他任务的ID
    /// </summary>
    [SugarColumn(ColumnDescription = "依赖任务ID", IsNullable = true)]
    public long? DependentOn { get; set; }
}